package cn.com.cifi.mars.web.action.fileUpload;

import cn.com.cifi.mars.bean.vo.price.FileDeleteVO;
import cn.com.cifi.mars.bean.vo.price.FilePreviewVO;
import cn.com.cifi.mars.bean.vo.price.FileUploadVO;
import cn.com.cifi.mars.common.bean.R;
import cn.com.cifi.mars.common.constants.VersionConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@Api(tags = "uploadAPI")
@RequestMapping("/${spring.data.rest.base-path}/{apiVersion}/fileUpload")
public interface IFileUpload {

    @ApiOperation(value = "上传文件", notes = "上传文件")
    @PostMapping(value = "upload")
    public R<FileUploadVO> fileUpload(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion") String apiVersion,
            @ApiParam(value = "项目id", required = false) @RequestParam(value = "projectId",required = false) String projectId,
            @ApiParam(value = "上传文件", required = true) @RequestParam(value = "file") MultipartFile file);

    @ApiOperation(value = "下载文件", notes = "下载文件")
    @GetMapping(value = "download")
    public void download(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion") String apiVersion,
            @ApiParam(value = "文件id", required = true) @RequestParam(value = "fileId", required = true) String fileId,
            HttpServletRequest request, HttpServletResponse response);

    @ApiOperation(value = "文件预览", notes = "文件预览")
    @GetMapping(value = "filePreview")
    public R<FilePreviewVO> filePreview(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion") String apiVersion,
            @ApiParam(value = "文件id", required = true) @RequestParam(value = "fileId", required = true) String fileId
            );

    @ApiOperation(value = "文件删除", notes = "文件删除")
    @DeleteMapping(value = "fileDelete")
    public R<FileDeleteVO> fileDelete(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion") String apiVersion,
            @ApiParam(value = "文件id", required = true) @RequestParam(value = "fileId") String fileId
    );

//    @ApiOperation(value = "文件转换测试", notes = "文件转换测试")
//    @DeleteMapping(value = "fileChange")
//    public R<Map<String,String>> fileChange(
//            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion") String apiVersion,
//            @ApiParam(value = "文件id", required = true) @RequestParam(value = "fileId") String fileId
//    );
}
